# Contributor: Sheila Aman <sheila@vulpine.house>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libwebp
pkgver=1.3.2
pkgrel=0
pkgdesc="Libraries for working with WebP images"
url="https://developers.google.com/speed/webp"
arch="all"
license="BSD-3-Clause"
makedepends="giflib-dev libjpeg-turbo-dev libpng-dev"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-tools
	libsharpyuv:_lib
	libwebpdecoder:_lib
	libwebpdemux:_lib
	libwebpmux:_lib
	"
source="https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-$pkgver.tar.gz"

# secfixes:
#   1.3.1-r1:
#     - CVE-2023-4863
#   1.3.0-r3:
#     - CVE-2023-1999

build() {
	CFLAGS="$CFLAGS -O2 -flto=auto -ffat-lto-objects" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-libwebpmux \
		--enable-libwebpdemux \
		--enable-libwebpdecoder \
		--disable-tiff # dependency-loop
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	install -Dm644 PATENTS README.md "$pkgdir"/usr/share/doc/$pkgname
}

tools() {
	pkgdesc="The WebP command line tools"
	amove usr/bin
}

_lib() {
	pkgdesc="$pkgdesc ($subpkgname library)"
	amove usr/lib/$subpkgname.so.*
}

sha512sums="
2b624d2ecfbff6b4db2719e38f146722638ae262acd96327073a04451dd05fb27ef70c5681187821d251df728a6be7e89209c861c561a13bfb786495a830bc20  libwebp-1.3.2.tar.gz
"
